home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok18.lha
/
Profile
/
Demos
/
Prim3.mod
< prev
next >
Wrap
Text File
|
1993-08-15
|
558b
|
35 lines
MODULE Prim3;
FROM InOut IMPORT WriteInt;
CONST n = 1000;
VAR i,f: INTEGER;
prims: ARRAY[2..n] OF BOOLEAN;
found: ARRAY[0..n] OF INTEGER;
PROCEDURE Mark(num: LONGINT; d: INTEGER);
BEGIN
REPEAT
IF (d<f) AND (num*found[d+1]<=n) THEN
Mark(num,d+1)
ELSE
prims[num] := FALSE
END;
num := num * found[d];
UNTIL num>n;
END Mark;
BEGIN
FOR i:=2 TO n DO prims[i] := TRUE END;
f := 0;
FOR i:=2 TO n DO
IF prims[i] THEN
found[f] := i; WriteInt(i,5);
Mark(i,0);
INC(f);
END;
END;
END Prim3.